<?php
namespace Admin\Common;


use Think\Auth;
use Think\Controller;
class CommonController extends Controller
{
//    防止非法登录
    public function __construct(){
      parent::__construct();
      if(!isset($_SESSION['aid'])){
          $url=__ROOT__.'/admin.php';
          header("location:$url");
      }
        //权限控制
//        $rule=MODULE_NAME.'/'.CONTROLLER_NAME.'/'.ACTION_NAME;
//        $auth=new Auth();
//        $res=$auth->check($rule,$_SESSION['aid']);
//        if(!$res){
//              $this->error('没有权限');die;
//        }
      if(method_exists($this,'__init')){
         $this->__init();
      }
    }

/**
 * 操作跳转
 */
    public function jump($res,$url1=null,$url2=null){
//        dd($res);die;
             if($res['valid']){
                 if(is_null($url1)){
                     $this->success($res['msg']);die;
                 }else{
                     $this->success($res['msg'],U($url1));die;
                 }
             }else{
                 if(is_null($url2)){
                     $this->error($res['msg']);die;
                 }else{
                     $this->error($res['msg'],U($url2));die;
                 }
             }
    }

}